package dialer.ws.business.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import dialer.ws.base.entity.Campaign;
import dialer.ws.base.exception.EntityException;
import dialer.ws.base.query.NamedQueryParameter;
import dialer.ws.base.service.impl.GenericServiceImpl;
import dialer.ws.business.dao.CampaignDAO;
import dialer.ws.business.service.CampaignService;

@Service("campaignService")
public class CampaignServiceImpl extends GenericServiceImpl<Campaign, Integer> implements CampaignService, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3730011721236921048L;

	private CampaignDAO campaignDAO;

	@Autowired
	public CampaignServiceImpl(CampaignDAO campaignDAO) {
		super(campaignDAO);
		this.campaignDAO = campaignDAO;
	}

	@Override
	public List<Campaign> getCampaignByState(String estado) {
		NamedQueryParameter param = new NamedQueryParameter("estatus", estado);
		try {
			return campaignDAO.findByNamedQueryNamedParameter("getCampaignByState", param);
		} catch (EntityException e) {
			log.error("### ERROR: " + e);
		}
		return new ArrayList<Campaign>();
	}

}
